package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.vo.BookInfoVO;
import com.briup.estore.service.BookService;
import com.briup.estore.service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/3 下午5:31
 * @Description 书籍详情展示
 **/
@WebServlet("/book/view")
public class BookViewServlet extends  BaseServlet {

    private BookService bookService=new BookServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userId = (String) req.getAttribute("userId");
        String id = req.getParameter("id");
        BookInfoVO vo  = bookService.getBookById(Integer.valueOf(id),Integer.parseInt(userId));
        writeData(resp, Result.success(vo));
    }
}
